<template>
	<Container>
		<view class="header">
			<view class="header-content" :style="{ background: 'url(' + assignment.backgroundUrl + ') 0 0 /100% 100%' }"><Article :articles="assignment.articles" /></view>
			<AudioIcon @iconTap="iconTap" :questionPress="questionPress" />
		</view>
		<Question :question="assignment.questionName" />
		<view class="articleBox">
			<view
				:class="{ success: chooses[index] === 'success', error: chooses[index] === 'error', hidden: chooses[index] === 'hidden' }"
				@tap="tap(item, index)"
				class="articles"
				v-for="(item, index) in assignment.optionArticles"
				:key="index"
			>
				<image class="item" mode="aspectFit" :src="item.imageUrl"></image>
				<text class="name">{{ item.name }}</text>
				<SuccessIcon v-if="chooses[index] === 'success'" />
			</view>
		</view>
	</Container>
</template>

<script>
import { mixins } from '../../../common/mixins/assignmentDefault.js'
import Article from '../article.vue'
import AudioIcon from '../audioIcon.vue'
import Question from '../questionName.vue'
import Container from '../container.vue'
import SuccessIcon from '../successIcon.vue'
export default {
	components: { Article, AudioIcon, Question, Container, SuccessIcon },	
	mixins: [mixins],
	methods: {
		tap: function(item, index) {
			if (this.isComplete) return
			this.isComplete = true
			if (item.isMatched) {
				this.optionStatus('success', index)
				this.assignment.optionArticles.map((item, current) => {
					if (index !== current) {
						this.optionStatus('hidden', current)
					}
				})
				this.$parent.next({
					isSure: true
				})
			} else {
				this.optionStatus('error', index)
				this.$parent.next()
			}
		}
	}
}
</script>

<style scoped lang="stylus">
.header
	height 45vh
	width 100%
	overflow hidden
	border-radius 70rpx
	border 12rpx solid #FCC77D
	box-sizing border-box
	transform translate3d(0, 0, 0)
	position relative
	margin 5vh 0
	.header-content
		position absolute
		height 100%
		width 1080rpx
		left 50%
		top 50%
		transform translate3d(-50%, -50%, 0)
		z-index 98
.articleBox
	width 100%
	height 40vh
	display flex
	flex-wrap wrap
	justify-content center
	align-items center
	.articles
		width 300rpx
		height 18vh
		max-width 28vh
		transition all 0.7s
		border 12rpx solid #FCC77D
		color #FFC268
		box-sizing border-box
		flex-direction column
		justify-content center
		align-items center
		text-align center
		display flex
		position relative
		border-radius 50rpx
		margin 0 20rpx 60rpx 20rpx
		.item
			height 80%
			width 70%
			filter drop-shadow(2px 0px #fff) drop-shadow(-2px 0px #fff) drop-shadow(0px -2px #fff) drop-shadow(0px 2px #fff) drop-shadow(2px 2px 1px #0000004a)
		.name
			position absolute
			bottom -60rpx
			font-size 34rpx
			font-weight 800
</style>
